package com.ibigcat.module.mdm.dao.mapper;

import java.util.*;

import com.ibigcat.framework.common.pojo.PageResult;
import com.ibigcat.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.ibigcat.framework.mybatis.core.mapper.BaseMapperX;
import com.ibigcat.module.mdm.dao.entity.CustomerDO;
import org.apache.ibatis.annotations.Mapper;
import com.ibigcat.module.mdm.controller.admin.customer.vo.*;

/**
 * 客户信息 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface CustomerMapper extends BaseMapperX<CustomerDO> {

    default PageResult<CustomerDO> selectPage(CustomerPageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CustomerDO>()
                .eqIfPresent(CustomerDO::getCustomerCode, reqVO.getCustomerCode())
                .likeIfPresent(CustomerDO::getCustomerName, reqVO.getCustomerName())
                .eqIfPresent(CustomerDO::getAbbreviation, reqVO.getAbbreviation())
                .eqIfPresent(CustomerDO::getContactPerson, reqVO.getContactPerson())
                .eqIfPresent(CustomerDO::getContactPersonPhone, reqVO.getContactPersonPhone())
                .eqIfPresent(CustomerDO::getMail, reqVO.getMail())
                .eqIfPresent(CustomerDO::getMainNature, reqVO.getMainNature())
                .eqIfPresent(CustomerDO::getTaxpayerType, reqVO.getTaxpayerType())
                .eqIfPresent(CustomerDO::getTaxpayerCode, reqVO.getTaxpayerCode())
                .eqIfPresent(CustomerDO::getCustomerType, reqVO.getCustomerType())
                .eqIfPresent(CustomerDO::getProvince, reqVO.getProvince())
                .eqIfPresent(CustomerDO::getCity, reqVO.getCity())
                .eqIfPresent(CustomerDO::getRegion, reqVO.getRegion())
                .eqIfPresent(CustomerDO::getAddress, reqVO.getAddress())
                .likeIfPresent(CustomerDO::getAccountBankName, reqVO.getAccountBankName())
                .eqIfPresent(CustomerDO::getAccountCode, reqVO.getAccountCode())
                .eqIfPresent(CustomerDO::getBusinessBrands, reqVO.getBusinessBrands())
                .eqIfPresent(CustomerDO::getServiceArea, reqVO.getServiceArea())
                .eqIfPresent(CustomerDO::getServiceType, reqVO.getServiceType())
                .eqIfPresent(CustomerDO::getUserCreateFlag, reqVO.getUserCreateFlag())
                .eqIfPresent(CustomerDO::getParkCode, reqVO.getParkCode())
                .eqIfPresent(CustomerDO::getDisabled, reqVO.getDisabled())
                .betweenIfPresent(CustomerDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(CustomerDO::getId));
    }

}